1. Technical Field
The present invention relates generally to an improved data processing system and in particular to a method and apparatus for processing data. Still more particularly, the present invention relates to a method, apparatus, and computer instructions for identifying memory leaks.
2. Description of Related Art
Data storage components, variables, collections, and multi-dimensional collections are used throughout all computer applications. During the execution of an application, the contents of these types of data storage elements will change or evolve. These changes occur due to modifications or updates to the data. These changes may be made by user input or through programmatic means.
In a Java virtual machine, a heap is a memory area, which contains all of the objects created by an application. During the course of executions, some objects may no longer be needed or used by an application. These types of objects are considered old objects. As more objects are created, the amount of space in the heap decreases. At some point in time, it is appropriate or useful to clear out or free objects that are no longer being used by an application. This process is referred to as garbage collection. In other words, the old objects are no longer needed by the program and can be removed or thrown out. This process involves memory recycling. When an object is old, the space in the heap occupied by this object may be recycled such that the space is made available for subsequent new objects. An object is considered old when the object is no longer referenced by a program or application. A program or application has a reference to an object, which allows the program or application to manipulate the object. A reference is similar to a pointer.
Even with memory recycling, memory leaks may occur. A memory leak is a condition caused by a program that does not free up the extra memory allocated by that program. When memory is allocated, but not deallocated, a memory leak occurs. In other words, the memory has leaked out of the computer. If too many memory leaks occur, these memory leaks can usurp all of memory and bring everything to a halt or slow the processing considerably.
In other environments, such as Java, the Java virtual machine (JVM) allocates and deallocates memory automatically. However, program level memory leaks can still occur. For example, programming errors can lead to object references still being held in a global data structure, which leads to reduced free space on the heap for allocating new objects. Memory leaks in a Java heap are currently very difficult to identify or diagnose. These types of memory leaks are especially difficult to determine or identify if the leak is intermittent or very slow. In some cases, a memory leak in a Java heap in a production system may take many days to manifest.
Currently, techniques used to find these leaks include tools such as Jinsight, Optimizeit profiler, and JPROF. Jinsight is a tool for visualizing and analyzing the execution of Java programs. Jinsight is available from Jinsight Informatica Ltda. Optimizeit profiler is a tool used to collect performance data during the execution of Java programs. Optimizeit profiler is available from Borland Software Corporation. JPROF is an IBM profiling tool, which is used to collect performance data pertaining to a running Java application.
These tools are all very invasive and require the use of the Java Virtual Machine Profiler Interface (JVMPI) to instrument the allocation path of the Java virtual machine (JVM) and to store information over time. JVMPI is an interface exposed by JVMs to enable tool vendors to develop profilers. This technique is much too heavy of a weight to employ in a product environment over the period of many days.
Therefore, it would be advantageous to have an improved method, apparatus, and computer instructions for determining memory leaks in a Java heap.